<template>
  <el-dialog
    v-el-drag-dialog
    title="编辑标签"
    :visible.sync="visible"
    width="500px"
    class="fillingImport"
    @closed="closed"
  >
    <el-form ref="form">
      <el-form-item label="单据标签:">
        <el-select v-model="fillingLabel" filterable clearable placeholder="请选择">
          <el-option
            v-for="item in fillingLabelList"
            :key="item.value"
            :label="item.keyName"
            :value="item.keyVal"
          />
        </el-select>
      </el-form-item>
    </el-form>
    <span slot="footer" class="btn-b">
      <el-button type="default" @click="cancel">取消</el-button>
      <el-button type="primary" @click="confirm">确定</el-button>
    </span>
  </el-dialog>
</template>

<script>
  import { updateFillingLabel } from '@/api'
  export default {
    name: '',
    props: {
      fillingLabelList: {
        type: Array,
        default: () => []
      }
    },
    data() {
      return {
        visible: false,
        fillingLabel: '',
        fillingInfo: []
      }
    },
    methods: {
      open(row) {
        return new Promise(resolve => {
          this.resolve = resolve
          this.visible = true
          if (row) {
            this.fillingInfo = JSON.parse(JSON.stringify(row))
          }
        })
      },
      closed() {
        this.fillingLabel = ''
        this.visible = false
      },
      cancel() {
        this.closed()
      },
      async confirm() {
        if (!this.fillingLabel) {
          this.$message.warning('请选择单据标签！')
          return
        }
        const params = {
          fillingIdList: this.fillingInfo,
          fillingLabel: this.fillingLabel
        }
        const res = await updateFillingLabel(params)
        if (res) {
          this.$message.success('操作成功！')
          this.closed()
          this.resolve()
        }
      }
    }

  }
</script>

<style>

</style>
